<?php
if (!defined('W_ROOT')) {
	exit();
}
$star = '<span style="color:red">*</span>';
$errormsg = (isset($_GET['error']) && $_GET['error'] != '') ? $_GET['error'] : '';
$first_name = $last_name = $username = $email = $password = "";

$sql = "SELECT * FROM tbluser WHERE id = $id";

$result = mysql_query($sql);
if(mysql_num_rows($result)){
	$row = mysql_fetch_array($result);

	$id = $row['id'];
	$first_name = $row['first_name'];
	$last_name = $row['last_name'];
	$username = $row['username'];
	$email = $row['email'];
	$password = $row['user_pass'];
	$type_id = $row['user_type_id'];
}
?>
	<div class="breadcrumb">
        <a href="<?php echo base_url_admin;?>"><?php echo $lang['HOME'];?></a>
         :: <a href="index.php?view=list"><?php echo $lang['LIST_USER'];?></a>
         :: <a href="#"><?php echo isset($_GET['id'])?$lang['EDIT']:$lang['INSERT'];?></a>
      </div>
<div class="heading">
	<h1><img src="../templates/image/user.png" alt="" />
		<?php
			echo $lang["PAGE"];
		?>
	</h1>
	<form action="<?php echo base_url_admin;?>/user/process.php?action=add" method="post" name="frmlist">
	<div class="buttons">
	<input class="button" type="submit" name="btnsave" value="<?php echo $lang['PUBLISH'] ;?>"/>
	<a href="<?php echo base_url_admin;?>/user/index.php?view=list" class="button"><?php echo $lang['BACK'];?></a></div>
</div>
<div class="content">
<form action="<?php echo base_url_admin;?>/user/process.php?action=add" method="post" name="frmlist">
<br/>

<?php
	if(!empty($_GET['error'])){
		echo "<div class='warning'>";

			switch ($_GET['error']){
				case "required":
					echo $lang['MESSAGE_REQUIR'];
					break;
				case "notequalemail":
					echo $lang['MESSAGE_NOTEQEMAIL'];
					break;
				case "notequalpass":
					echo $lang['MESSAGE_NOTEQPASS'];
					break;
				case "invalidemail":
					echo $lang['MESSAGE_INVALID'];
					break;

			}
		echo "</div>";
	}
        ?>
<table cellpadding="5" cellspacing="5" border="0" width="100%" align="center">
<tr>
<td colspan="3" align="left"><strong style="color:#F00;">*<!-- are requirement--><?php echo $lang['NOTESTAR'];?></strong></td>
</tr>
<tr>
   <td width="10%" height="30" align="left" valign="top"><!--User Type--><?php echo $lang['USERTYPEE'];?><?php echo $star;?></td>
   <td width="5%" align="left" valign="top">:</td>
   <td width="80%" align="left">
       <select name="type">
       <option value=""><?php echo $lang['SELCTUSRTYYPE'];?></option>
       <?php
	  // echo $type_id.'testign'; die();
       $sql_type = "SELECT user_type_id,user_type_name FROM tbluser_type ";
       $result_type = mysql_query($sql_type);
    while($row_type = mysql_fetch_assoc($result_type)) {
        ?>
        <option <?php echo (@$type_id==$row_type['user_type_id'])?"selected":"";?> value="<?php echo $row_type['user_type_id']; ?>" <?php //echo($row_type['user_type_id']==$type_id)?' selected="selected"':''?>><?php echo $row_type['user_type_name'] ?></option>
        <?php
    } // end while

        ?>

        </select>
   </td>
</tr>
<tr>
   <td width="10%" height="30" align="left" valign="top"><!--First Name--><?php echo $lang['SHIP_FIR_NAME'] ;?></td>
   <td width="5%" align="left" valign="top">:</td>
   <td width="80%" align="left">
        <input size="50" name="txttitle" type="text"  alt="required" id="txttitle"  value="<?php echo $first_name;?>"  />
   </td>
</tr>
<tr>
   <td width="10%" height="30" align="left" valign="top"><!--Last Name--><?php echo $lang['SHIP_LAS_NAME'];?></td>
   <td width="5%" align="left" valign="top">:</td>
   <td width="80%" align="left">
        <input size="50" name="txtmeta_key" type="text"  id="txtmeta_key"  value="<?php echo $last_name;?>"  />
   </td>
</tr>
<tr>
   <td width="10%" height="30" align="left" valign="top"><!--Username--><?php echo $lang['USRNAMEME'];?><?php echo $star;?></td>
   <td width="5%" align="left" valign="top">:</td>
   <td width="80%" align="left">
        <input size="50" name="txtmeta_desc" type="text"  id="txtmeta_desc"  value="<?php echo $username;?>" required />
   </td>
</tr>
<tr>
   <td width="10%" height="30" align="left" valign="top"><!--Email Address--><?php echo $lang['LOG_EMAIL'];?><?php echo $star;?></td>
   <td width="5%" align="left" valign="top">:</td>
   <td width="80%" align="left">
        <input size="50" name="txtemail" type="text"  id="txtemail"  value="<?php echo $email;?>" required />
   </td>
</tr>
<tr>
   <td width="10%" height="30" align="left" valign="top"><!--Confirm Email--><?php echo $lang['CONFIRMEMAILL'];?><?php echo $star;?></td>
   <td width="5%" align="left" valign="top">:</td>
   <td width="80%" align="left">
        <input size="50" name="txtconemail" type="text"  id="txtconemail"  value="<?php echo $email;?>" required />

   </td>
</tr>
<tr>
   <td width="10%" height="30" align="left" valign="top"><!--Password--><?php echo $lang['LOG_PASSWORD'];?><?php echo empty($id) ? $star : '';?></td>
   <td width="5%" align="left" valign="top">:</td>
   <td width="80%" align="left">
        <input size="50" name="txtpass" type="password"  id="txtpass" value="" <?php echo empty($id) ? 'required' : ''?> />
   </td>
</tr>
<tr>
   <td width="10%" height="30" align="left" valign="top"><!--Confirm Password--><?php echo $lang['CONFIRMPASSWORDS'];?><?php echo empty($id) ? $star : '';?></td>
   <td width="5%" align="left" valign="top">:</td>
   <td width="80%" align="left">
        <input size="50" name="txtconpass" type="password"  id="txtconpass" value="" <?php echo empty($id) ? 'required' : ''?> />
        
   </td>
</tr>
<input type="hidden" name="hidid" value="<?php echo $id;?>" />
<tr>
<td>&nbsp;</td>
</tr>
</table>

</form>
</div>
</div><!--<div class="row">-->